import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [
      {
        path: 'dashboard',
        name: 'Dashboard',
        component: () => import('@/views/dashboard/index'),
        meta: { title: '首页', icon: 'dashboard' }
      }
    ]
  },
  // 陈继欢
  {
    path: '/example',
    component: Layout,
    redirect: '/example',
    name: 'Example',
    meta: {
      title: '停车管理',
      icon: 'el-icon-truck'
    },
    children: [
      {
        path: 'site_rent',
        name: 'SiteRent',
        component: () => import('@/views/example/components/site_rent'),
        meta: {
          title: '停车场管理',
          icon: 'el-icon-position'
        }
      }, {
        path: 'site_rents',
        name: 'SiteRents',
        component: () => import('@/views/example/components/site_rents'),
        meta: {
          title: '停车卡管理',
          icon: 'el-icon-share'
        }
      }, {
        path: 'site_order',
        name: 'SiteOrder',
        component: () => import('@/views/example/components/site_order'),
        meta: {
          title: '停车订单管理',
          icon: 'el-icon-ship'
        }
      }, {
        path: 'site_collect',
        name: 'SiteCollect',
        component: () => import('@/views/example/components/site_collect'),
        meta: {
          title: '收费细节管理',
          icon: 'el-icon-ship'
        }
      }
    ]
  },
  // 刘腾
  {
    path: '/jcxx',
    component: Layout,
    redirect: '/jcxx/dase',
    name: 'jcxx',
    meta: { title: '基础信息表', icon: 'el-icon-sell' },
    children: [
      {
        path: '/position',
        name: 'position_config',
        component: () => import('@/views/base/position/index'),
        meta: {
          title: '职位配置',
          icon: 'el-icon-view'
        }
      },
      {
        path: '/unit',
        name: 'unit',
        component: () => import('@/views/base/unit/index'),
        meta: {
          title: '单元管理',
          icon: 'el-icon-school'
        }
      },
      {
        path: '/room',
        name: 'room',
        component: () => import('@/views/base/room/index'),
        meta: {
          title: '房间管理',
          icon: 'el-icon-house'
        }
      }
    ]
  },
  // 肖宇
  {
    path: '/operate',
    component: Layout,
    redirect: '/operate/table',
    name: 'operate',
    meta: { title: '社区运营' },
    children: [
      {
        path: 'table',
        name: 'Table',
        component: () => import('@/views/table/index'),
        meta: { title: '跳蚤市场' }
      }, {
        path: 'operate',
        name: 'operate',
        component: () => import('@/views/operate/index'),
        meta: { title: '商品市场' }
      }
    ]
  },
  // 姚瑞涛
  {
    path: '/APP',
    component: Layout,
    redirect: '/example/table',
    name: 'APP',
    meta: { title: 'APP管理', icon: 'el-icon-user' },
    children: [
      {
        path: '/advertising',
        name: 'advertising',
        component: () => import('@/views/app/advertising/index'),
        meta: { title: '广告管理', icon: 'el-icon-user' }
      }, {
        path: '/announcement',
        name: 'announcement',
        component: () => import('@/views/app/announcement/index'),
        meta: { title: '公告管理', icon: 'el-icon-user' }
      }, {
        path: '/information',
        name: 'information',
        component: () => import('@/views/app/information/index'),
        meta: { title: '公告管理', icon: 'el-icon-user' }
      }
    ]
  },
  // 王浩
  {
    path: '/community',
    name: 'community',
    component: Layout,
    redirect: '/community/square',
    meta: { title: '社区交流', icon: 'el-icon-connection' },
    children: [
      {
        path: '/community/square',
        name: 'square',
        component: () => import('@/views/community/square/index'),
        meta: {
          title: '广场',
          icon: 'el-icon-chat-square'
        }
      },
      {
        path: '/community/secondhand',
        name: 'secondhand',
        component: () => import('@/views/community/secondhand/index'),
        meta: {
          title: '二手',
          icon: 'el-icon-sold-out'
        }
      },
      {
        path: '/community/cooperation',
        name: 'cooperation',
        component: () => import('@/views/community/cooperation/index'),
        meta: {
          title: '互助',
          icon: 'el-icon-help'
        }
      },
      {
        path: '/community/carpool',
        name: 'carpool',
        component: () => import('@/views/community/carpool/index'),
        meta: {
          title: '拼车',
          icon: 'el-icon-position'
        }
      }
    ]
  },
  // 刘倩
  {
    path: '/management',
    name: 'management',
    redirect: '/management',
    component: Layout,
    meta: {
      title: '社区管理',
      icon: 'article'
    },
    children: [
      {
        path: '',
        name: 'notic',
        component: () => import('@/views/qianqian/notic'),
        children: [{
          path: '/notic',
          name: 'notic',

          meta: { title: '通知管理',
            icon: 'personnel-info'
          }
        }]

      }, {
        path: '/check',
        name: 'check',
        component: () => import('@/views/qianqian/check'),
        children: [{
          path: '/check',
          name: 'check',
          meta: {
            title: '考勤管理',
            icon: 'form'
          }

        }]
      }, {
        path: '/purchase',
        name: 'purchase',
        component: () => import('@/views/qianqian/purchase'),
        children: [{
          path: '/purchase',
          naem: 'purchase',
          meta: {
            title: '采购管理',
            icon: 'introduce'
          }
        }]
      }
    ]

  }, {
    path: '/SystemManagement',
    component: Layout,
    redirect: '/SystemManagement/role',
    name: 'SystemManagement',
    meta: { title: '系统管理' },
    children: [
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/SystemManagement/role'),
        meta: { title: '角色管理' }
      },
      {
        path: 'manager',
        name: 'manager',
        component: () => import('@/views/SystemManagement/manager'),
        meta: { title: '管理员管理' }
      },
      {
        path: 'user',
        name: 'user',
        component: () => import('@/views/SystemManagement/user'),
        meta: { title: '用户管理' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]
// export const constnewRouter = [
//   management
// ]

const createRouter = () =>
  new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes
  })

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
